// Achievement by G3X / GeXeH - Enjoy
// Version 1.0

// Achievement: Enter 100 Jalopies.

if ( !file.Exists( "../models/Vehicle.mdl" ) ) then return end // No EP2.

local Value = achievements.GetValue( "Jalopy Frenzy", "total", 0 )
local Status = false

local function Update()

	if (Value != 100) then
		// print("Check Started.\n")
		local ply = LocalPlayer()

		if (!ValidEntity( ply )) then return end
		
		if ( (ply:InVehicle()) && (ply:GetVehicle():GetClass() == "prop_vehicle_jeep") && !(ply:GetVehicle():GetModel() == "models/buggy.mdl") ) then
			if !Status then
				Status = true
				// print("Player Inside Jalopy.\n")
				Value = math.Clamp( Value + 1, 0, 100 )
				achievements.SetValue( "Jalopy Frenzy", "total", Value )
				achievements.Update( "Jalopy Frenzy", Value / 100, Value .. "/100" )
			end
		else
			Status = false
			// print("Player Outside Jalopy.\n")
		end

		// print("Check Ended.\n")
	
	else
		timer.Destroy("Achievement.JalopyFrenzy")
	end

end

timer.Create("Achievement.JalopyFrenzy", 1, 0, Update)

achievements.Register( "Jalopy Frenzy", "Enter 100 Jalopies.", "achievements/jalopyfrenzy", Value / 100, Value .. "/100" )